# Contributor: Daniel Sabogal <dsabogalcc@gmail.com>
# Maintainer:
pkgname=octave
pkgver=5.2.0
pkgrel=0
pkgdesc="A high-level language, primarily intended for numerical computations"
url="https://www.gnu.org/software/octave/"
# x86: missing tex dependencies
# mips: missing openblas
# armv7, armhf, x86: missing openjdk11
arch="all !x86 !armv7 !ppc64le !mips !mips64 !s390x !armhf"
license="GPL-3.0-or-later"
subpackages="$pkgname-doc"
_jdkver=11
_jhome=/usr/lib/jvm/java-"$_jdkver"-openjdk
makedepends="autoconf automake libtool bison curl curl-dev fftw-dev fltk-dev fontconfig-dev
	freetype-dev gfortran glu-dev gnuplot imagemagick-dev hdf5-dev portaudio-dev
	lapack-dev libsm-dev libltdl lcms2-dev openblas-dev pcre-dev perl pkgconf qt5-qttools-dev
	readline-dev texinfo zlib-dev texlive texlive-dvi openjdk$_jdkver zip qhull-dev
	ghostscript-dev libsndfile-dev graphicsmagick-dev suitesparse-dev xz-dev"
source="https://ftpmirror.gnu.org/octave/octave-$pkgver.tar.gz
	libinterp-deps.patch
	abs.patch
	"

prepare() {
	default_prepare

	autoreconf -vif
}

build() {
	export JAVA_HOME=$_jhome
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-shared \
		--disable-static
	make
}

check() {
	make LD_LIBRARY_PATH=$_jhome/lib/server check
}

package() {
	make DESTDIR="$pkgdir/" \
		-C "$builddir" install
	rm -rf "$pkgdir"/usr/lib/charset.alias
	rm -rf "$pkgdir"/usr/share/octave/"$pkgver"/etc/tests
}

sha512sums="fa2076fb22415e0797964c66cfb8d24643f178f45eb9c14ebb4c082767e0a53509fde550f579fa4a816348bd0f7cbc74f24144f9a30a5b9c09ebe1b3949db498  octave-5.2.0.tar.gz
f449d84ec0b9e18919473d9efc5b6628dc9eb62bbb4fe8160ef9c280546b7b2f07ea803992240063685ec4e8519b80002c752647060fc438e6dce8d464b98b6d  libinterp-deps.patch
f6cd1a52686a66d9914029b3c70eba88d2468700abfb16c3bdc5c0bae2a29cbf06143e15c2828be1112d45403247ff5713edf1b1261eaf132465ac05df6c7c7c  abs.patch"
